package com.bjsxt.common.interceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.bjsxt.users.pojo.AAdmins;
import com.bjsxt.users.service.IUsersService;

@Component("adminsAuthInterceptor")
public class AdminsAuthInterceptor extends HandlerInterceptorAdapter {
	@Resource
	private IUsersService usersService;

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session=request.getSession();
		AAdmins admins=(AAdmins)session.getAttribute("admins");
		if(admins!=null){
			//已经登陆
			return true;
		}
		String info="请先登录";
		session.setAttribute("info",info);
		response.sendRedirect(request.getContextPath()+"/adminsLogin.htm");
		
		return false;
	}
	
	
}
